<template>
    <div class="container"><error-tip :errorCode="errorCode" v-if="errorCode"></error-tip>
        <div v-else>
            <year-list :data="yearData"></year-list>
        </div>
    </div>
</template>

<script>
import { onMounted, computed } from 'vue'
import { useStore } from 'vuex'
import getData from '@/services'
import { getNowDate } from '@/libs/utils'
import YearList from '@/components/YearPage/List.vue'


export default {
    // 生命周期函数
    setup() {
        const store = useStore()

        onMounted(() => { // 页面加载完成后执行的函数
            const field = store.state.field
            getData(store, field, getNowDate(field))
        })

        return {
            yearData: computed(() => store.state.yearData),
            errorCode: computed(() => store.state.errorCode)
        }
    },
    components: {
        YearList
    }
}
</script>

<style lang="less" scoped>
    
</style>